<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>旧的方式创建模块</title>
    <script src="js/traceur.js"></script>
    <script src="js/bootstrap.js"></script>
    <script type="module">

        //使用立即调用表达式来创建模块IIFE
        (function (window) {
            var sum = function (x, y) {
                return x + y;
            }
            var sub = function (x, y) {
                return x - y;
            }
            var math = {
                findSum: function (a, b) {
                    return sum(a, b);
                },
                findSub: function (a, b) {
                    return sub(a, b);
                }
            }
            window.math = math; //将math变量导出给主程序中
        })(window)
        console.log(math.findSum(1, 2)); // "3"
        console.log(math.findSub(1, 2)); //"-1"

    </script>
</head>
<body>

</body>
</html>